import java.awt.*;
import java.awt.event.*;
import java.awt.AWTException;

public class ServerControl {
	private static ServerControl instance= null;
	private Robot robot = null;
	private Toolkit toolkit = null;
	private int conW, conH;
	
	
	public ServerControl() throws AWTException {
		robot = new Robot();
		toolkit = Toolkit.getDefaultToolkit();
		conW = toolkit.getScreenSize().width;
		conH = toolkit.getScreenSize().height;
	}
	private static ServerControl getInstance() throws AWTException {
		if(instance == null)
			instance = new ServerControl();
		return instance;
	}
	public void setMouseMove(int x, int y) {
		int rW = toolkit.getScreenSize().width;
		int rH = toolkit.getScreenSize().height;
		
		int cX = (int)((float)x * (float)((float)rW / (float)this.conW));
		int cY = (int)((float)y * (float)((float)rH / (float)this.conH));
		
		System.out.println("mouse move :" + cX + ":" +cY);
		robot.mouseMove(cX, cY);
		robot.mousePress(InputEvent.BUTTON1_MASK);
		robot.mouseRelease(InputEvent.BUTTON1_MASK);
	}
	public int getConW() {
		return conW;
	}
	public int getConH() {
		return conH;
	}
	public void setConvSize(int conW, int conH) {
		conW = conW;
		conH = conH;
	}

}
